#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const int N = 1e6 + 10;
LL n, m;
LL a[N];

LL solve(LL x)
{
    LL ret = 0;
    for(int i = 0; i < n; i++)
    {
        if(a[i] > x) ret += a[i] - x;
    }
    return ret;
}
int main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    int left = 0, right = 2e9;
    while(left < right)
    {
        int mid = left + (right - left + 1) / 2;
        if(solve(mid) >= m) left = mid;
        else right = mid - 1;
    }
    cout << left << endl;
    return 0;
}
